package thread;

import static java.lang.Thread.sleep;

class MyThread extends Thread{

    // Run方法相当于线程的入口
    public void run(){
        while(true){
            System.out.println("Hello thread!");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread T = new MyThread();

        //在系统中创建一个新线程
        T.start();
        //T.run();

        while (true){
            System.out.println("Hello world!");
            sleep(1000);
        }
    }
}
